home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13197 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: labdien.cc.columbia.edu!ski1
  2. From: ski1@labdien.cc.columbia.edu (Sam Inala)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How can I use huge || very small number?
  5. Date: 5 Apr 1996 04:23:36 GMT
  6. Organization: Columbia University
  7. Message-ID: <4k2788$85f@apakabar.cc.columbia.edu>
  8. References: <315681F3.314D@blue.nowcom.co.kr> <4joh0l$jch@news.acns.nwu.edu>
  9. Reply-To: ski1@columbia.edu
  10. NNTP-Posting-Host: labdien.cc.columbia.edu
  11. Keywords: 1000 factorial
  12.  
  13. Thus spake muzaffar@casbah.acns.nwu.edu (Usman Muzaffar):
  14. >In article <315681F3.314D@blue.nowcom.co.kr>,
  15. >whoever  <whatever@blue.nowcom.co.kr> wrote:
  16. >>may be it is FAQ but...
  17. >>how can I compute 10000! or 0.12345......
  18. >
  19. >10000! is a very, very big number.
  20. >I'm not sure it's even representable by standard IEEE fp notation.
  21.  
  22. One approach that I haven't seen mentioned is this:
  23.  
  24. 1000! = exp( log( 1000 ! ) )
  25.  
  26. Let sum = Sum( log10( i ), i=1..1000 )
  27.  
  28. The integer part of sum is your exponent, as a power of 10.
  29. The mantissa is 10 to the sum power.
  30.  
  31. --
  32. 'Til next time,                \o/   \o/
  33.                                 V \o/ V     email: ski1@columbia.edu
  34. <>  Sam  Inala  <>                 V
  35.